<?php
declare (strict_types = 1);

namespace app\validate\api;

use think\Validate;

/**
 * 阴阳师验证器
 * Class Index
 * @package app\index\validate
 */
class Ah extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'user_id'   => 'require',
        'nickname'   => 'require',
        'avatar'   => 'require',
        'outfit_id'   => 'require',
        'role_id'   => 'number',
        'page'      => 'number',
        'limit'     => 'number',
        'category'     => 'require|in:hall,my',
        'order'     => 'require|in:hot,new,collect,create',
        'play_style_id'     => 'array',
        'action'     => 'require|in:yes,no',
        'name'     => 'require',
        'description'     => 'require',
        'detail'     => 'require',
        'attr'     => 'max:100',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'user_id.require'  => '缺少user_id',
        'nickname.require'  => '缺少用户昵称',
        'avatar.require'  => '缺少用户头像',
        'name.require'  => '缺少配装名称',
        'outfit_id.require'  => '缺少outfit_id配装id',
        'role_id.number'  => 'role_id必须为数字',
        'page.number'     => 'page必须为数字',
        'limit.number'    => 'limit必须为数字',
        'category.require'    => '请选择场景',
        'category.in'    => '场景格式错误',
        'order.require'    => '请选择分类排序方式',
        'order.in'    => '分类排序方式格式错误',
        'action.require'    => '请选择操作类型',
        'description.require'    => '配装描述必填',
        'detail.require'    => '配装详情必填',
        'attr.max'    => '长度不能超过100字符',
    ];
    protected $scene = [
        'list'   =>  ['user_id','page','limit','role_id','category','order','play_style_id'],
        'collect'   =>  ['user_id','outfit_id','action'],
        'publish'   =>  ['user_id','outfit_id','action'],
        'add' => ['user_id','nickname','avatar','name','role_id','description','detail','play_style_id','attr'],
        'edit' => ['outfit_id','user_id','nickname','avatar','name','role_id','description','detail','play_style_id','attr'],
        'detail' => ['outfit_id','user_id'],
    ];

}
